<?php

// 获取资讯列表
// GET information.volist

namespace app\api\resource\information;
use think\Db;
use app\api\lib\Page;

class Volist
{
    // 方法
    public $_method = ['GET'];
    // 前置
    public $_pre    = [];
    // 描述
    public $_description = '获取资讯列表';
    // 参数
    public $_param  = [
    ];
    // 返回
    public $_return = [
        200 => '获取成功',
    ];

    public function run(&$request)
    {
        $page  = $request->get('page/d',1,'abs');
        $show  = $request->get('show/d',10,'abs');

        $table = 'information';
        $where = '';
        $list = Db::name($table)->where($where)->order('id desc')->page($page,$show)->select();

        if ( !empty($list) ) {
            foreach ($list as $key => $val) {
                $list[$key]['content'] = mb_substr($list[$key]['content'],0,40,'utf-8');
            }
        }

        $pagelist = Page::run($table, $page, $show, $where, $list);

        return [200,$pagelist];
    }
}